<?php

namespace app\model\zs;

use think\Model;

class ZsMemberArticleComment extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'member_article_comments';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    // 自动写入时间的类型
    protected $autoWriteTimestamp = 'datetime';

    // 定义时间戳字段名
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';

    const STATUS_ON = 1;
    const STATUS_OFF = 2;

    const AUDIT_STATUS_WAIT = 1;
    const AUDIT_STATUS_PASS = 2;
    const AUDIT_STATUS_FAIL = 3;

    public function memberUser()
    {
        return $this->belongsTo(ZsMemberMeal::class, 'vipcode', 'vipcode');
    }

    public function replyMemberUser()
    {
        return $this->belongsTo(ZsMemberMeal::class, 'reply_vipcode', 'vipcode');
    }

    public function articleModel()
    {
        return $this->belongsTo(ZsMemberArticle::class, 'article_id', 'id');
    }

    /**
     * 状态对应文本
     */
    public static function statusRels()
    {
        return [
            static::STATUS_ON => '启用',
            static::STATUS_OFF => '禁用',
        ];
    }

    /**
     * 状态对应css class名称
     */
    public static function statusClassRels()
    {
        return [
            static::STATUS_ON => '',
            static::STATUS_OFF => 'color-red',
        ];
    }

    /**
     * 审核状态对应文本
     */
    public static function auditStatusRels()
    {
        return [
            static::AUDIT_STATUS_WAIT => '待审核',
            static::AUDIT_STATUS_PASS => '审核通过',
            static::AUDIT_STATUS_FAIL => '审核驳回',
        ];
    }

    /**
     * 审核状态对应css class名称
     */
    public static function auditStatusClassRels()
    {
        return [
            static::AUDIT_STATUS_WAIT => '',
            static::AUDIT_STATUS_PASS => 'color-green',
            static::AUDIT_STATUS_FAIL => 'color-red',
        ];
    }

    /**
     * 审核状态对应文本（小程序端）
     * - 审核通过状态不显示在小程序端
     */
    public static function auditStatusRelsMini()
    {
        return [
            static::AUDIT_STATUS_WAIT => '待审核',
            // static::AUDIT_STATUS_PASS => '审核通过',
            static::AUDIT_STATUS_FAIL => '审核驳回',
        ];
    }

    /**
     * 审核状态对应css class名称（小程序端）
     */
    public static function auditStatusClassRelsMini()
    {
        return [
            static::AUDIT_STATUS_WAIT => 'u-type-warning-dark',
            static::AUDIT_STATUS_PASS => '',
            static::AUDIT_STATUS_FAIL => 'u-type-error-dark',
        ];
    }
}
